Skip to content

Add auto-import retry to getCompletionsAtPosition in API - #64133

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
auvred:api-auto-import-completion-retry
Sep 4, 2026
Merged

Add auto-import retry to getCompletionsAtPosition in API#64133
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
auvred:api-auto-import-completion-retry

Conversation

@auvred

@auvred auvred commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #64132

This PR adds a retry with (*Session).GetSnapshotWithAutoImports similar to

if errors.Is(lsErr, ls.ErrNeedsAutoImports) {
languageService, lsErr = s.session.GetLanguageServiceWithAutoImports(ctx, snapshot, params.TextDocumentURI())
if lsErr != nil {
return lsErr
}
if ctx.Err() != nil {
return ctx.Err()
}
resp, lsErr = fn(s, ctx, languageService, params)
if errors.Is(lsErr, ls.ErrNeedsAutoImports) {
panic(info.Method + " returned ErrNeedsAutoImports even after enabling auto imports")
}
}

Copilot AI balanced review requested due to automatic review settings September 2, 2026 13:34
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 2, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The retry path must propagate cancellation after auto-import snapshot preparation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds API completion retry support when auto-import data is required.

Changes:

  • Retries completions using an auto-import-prepared snapshot.
  • Generalizes language-service setup for alternate snapshots.
  • Adds an auto-import completion regression test.
File summaries
File Description
tsc/internal/api/session.go Implements snapshot preparation and completion retry.
tsc/internal/api/session_completion_test.go Verifies auto-import completions are returned.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tsc/internal/api/session.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you planning to include a fix for #64166 here, or should I follow up after this is merged?

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 4, 2026
@auvred

auvred commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

The #64166 diff is rather large, so it's probably better to review it separately

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Sep 4, 2026
Merged via the queue into microsoft:main with commit b6634d8 Sep 4, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

getCompletionsAtPosition in API throws "completion list needs auto imports"

3 participants